<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>作品详情</title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>

		<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/miva.utils.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/miva.components.vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>

		<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/locale/zh-cn.js"></script>

		<link rel="stylesheet" type="text/less" href="../css/entry.less"/>
    <script src="../js/less.js" type="text/javascript" charset="utf-8"></script>

	</head>
	<body>
    <div id="app">
      <header class="mui-bar mui-bar-nav">
  			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  			<h1 class="mui-title">作品详情</h1>
  		</header>
  		<div class="mui-content">
  			<frame-work-book type="4" :book-data="bookData"></frame-work-book>

				<div @tap="gotoBookCatalog" class="total-chapter"><i class="iconfont icon-mulu"></i><span>共80章</span></div>

				<frame-work-comment :comment-list="commentList" style="background:#fff"></frame-work-comment>

  		</div>
    </div>

    <script type="text/javascript">

      new Vue({
        el: '#app',
        data: {
          bookId: mivaUtils.getBookId(window.location.search),
					bookData: [],
					commentList: [],
        },
				components: {
					frameWorkBook: miva.frameWorkBook,
					frameWorkComment: miva.frameWorkComment,
				},
				created() {
					const _this = this;


					// 获取书籍信息
					const params = new URLSearchParams();
					params.append('novel_id', _this.bookId);
					axios.post(
						mivaUtils.baseUri + '/Mobile/Index/novelDetail',
						params,
						{'Content-Type': 'application/x-www-form-urlencoded'}
					).then(function (response) {
				    _this.bookData.push(response.data.result.novel);
				  })

					// 获取评论列表
					params.append('p', 1)
					axios.post(
						mivaUtils.baseUri + '/Mobile/Index/novelComment',
						params,
						{'Content-Type': 'application/x-www-form-urlencoded'}
					).then(function (response) {
							_this.commentList = response.data.result.comment;
					    console.log(response.data.result.comment);
					  })

				},
        mounted: function() {

        },
        methods: {
					gotoBookCatalog() {
						mui.openWindow({
							url: './bookCatalog.html?id='+this.bookId,
							id: 'bookCatalog',
						})
					},
				}
      })
    </script>
	</body>
</html>
